package com.jwx.mycar.utils;



import com.jwx.mycar.common.ResultData;
import com.jwx.mycar.entity.vo.ResultVo;
import org.springframework.stereotype.Component;

/**
 * Description:返回数据方法工具类
 *
 * @author jwx
 * Createtime:2019/11/10 14:59
 **/
@Component
public class ResultVOUtil {

    public ResultVo success(){
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(ResultData.ResultEnum.SUCCESS.getCode());
        resultVO.setMsg(ResultData.ResultEnum.SUCCESS.getMsg());
        return resultVO;
    }

    public ResultVo success(Object data){
        ResultVo resultVO = this.success();//直接获取前面的方法内容
        resultVO.setData(data);
        return resultVO;
    }

    public ResultVo success(String msg, Object data){
        ResultVo resultVO = this.success(data);
        resultVO.setMsg(msg);
        return resultVO;
    }

    public ResultVo fail(){
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(ResultData.ResultEnum.FAIl.getCode());
        resultVO.setMsg(ResultData.ResultEnum.FAIl.getMsg());
        return resultVO;
    }

    public ResultVo fail(Object data){
        ResultVo resultVO = this.fail();//直接获取前面的方法内容
        resultVO.setData(data);
        return resultVO;
    }

    public ResultVo fail(String msg, Object data){
        ResultVo resultVO = this.fail(data);
        resultVO.setMsg(msg);
        return resultVO;
    }

    public ResultVo unkonwError(){
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(ResultData.ResultEnum.UNKNOWN_ERROR.getCode());
        resultVO.setMsg(ResultData.ResultEnum.UNKNOWN_ERROR.getMsg());
        return resultVO;
    }
    public ResultVo unkonwError(Object data){
        ResultVo resultVO = this.unkonwError();
        resultVO.setData(data);
        return resultVO;
    }


}
